package top.liujingyanghui.crypto.mybatisplus.param;

import lombok.Data;
import top.liujingyanghui.crypto.mybatis.annotation.CryptoClass;
import top.liujingyanghui.crypto.mybatis.annotation.CryptoKey;
import top.liujingyanghui.crypto.mybatis.annotation.CryptoString;
import top.liujingyanghui.crypto.mybatisplus.rule.PhoneCryptoRule;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * @author : wdh
 * @since : 2022/5/26 11:10
 */
@Data
@CryptoClass
public class UserParam implements Serializable {

    @CryptoClass   // 对象中包含实体，实体中有字段需要加密，属性需要加@SensitiveClass
    private UserItem userItem;

    @CryptoString(rule = PhoneCryptoRule.class)  // 集合是String的情况
    private List<String> phones;

    @CryptoClass // 集合是实体时，实体中有字段需要加密，属性需要加@SensitiveClass
    private List<UserItem> phoneList;

    @CryptoKey(key = "phone", rule = PhoneCryptoRule.class)  // 集合是Map的情况
    private List<Map<String, String>> phoneMap;

    @CryptoString(rule = PhoneCryptoRule.class) // 集合是Map的情况
    private String[] phoneArray;

    @Data
    public static class UserItem implements Serializable{
        @CryptoString(rule = PhoneCryptoRule.class)
        private String phone;
    }
}
